<?php

/*
*
* BEGIN user_management_ui.php
*
*
* Dazzler User Management UIs
* @Description: The class creates all the UIs for the user management
* @Authors: Salman, Wits University
* @Copyright: © Wits University 2011 - All Rights Reserved
* @License: BSD License (http://www.linfo.org/bsdlicense.html)
*
*
* BEGIN CHANGELOG
* Developers working on thee files are REQUIRED to maintain this CHANGELOG.
* Please ensure you follow the Changelog Guidelines: http://code.google.com/p/dazzler/wiki/DazzlerDevelopGuideline?ts=1315476570&updated=DazzlerDevelopGuideline
* !==================================================================================================================================================================
*
* VERSION 1.0.0
*	+ File Created, Salman, 10 September 2011
*
* ==================================================================================================================================================================!
* END CHANGELOG
*/


/*******************************************************************************************************************************************************************
*
* BEGIN Direct Call Check
*
/******************************************************************************************************************************************************************/
global $doNotCallThisScriptDirectly;
if ($doNotCallThisScriptDirectly != 1)
{
	/* Read the ini language file */
	$ini_lang_array = array();
	$clientlang = explode(",", strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']));
	$lang_ini_array = (file_exists("lang/" . trim($clientlang[0]) . ".ini")) ? parse_ini_file("lang/" . trim($clientlang[0]) . ".ini", true) : parse_ini_file("lang/en.ini", true);
	die ($lang_ini_array['ERRORS']['doNotCallThisScriptDirectly']);
}
/*******************************************************************************************************************************************************************
*
* END Direct Call Check
*
/******************************************************************************************************************************************************************/

class user_management_ui extends baseClass
{

    private $html_builder;
    private $parsesiteconfig;
    
    public function  __construct()
    {
    $this->html_builder = new htmlelementsbuilder();
    $this->parsesiteconfig = new parsesiteconfig();
    }

      /**
     * \brief Builds html content for the login window.
     * return Returns the html content for the login window.
     */
    private function buildWebLoginWindow()
    {
        //$loginWindow = "<div id='loginWindow' class='ui-widget-content ui-corner-all'style='border:1px solid #CCCCCC;padding:20px 20px 20px 20px; width:350px; float:left; clear:left;'> ";
        //$loginWindow .=  "<div class='ui-widget-content ui-corner-all'style='border:1px solid #CCCCCC;padding:5px 50px 5px 100px;'> ".
       // $this->html_builder->buildButton("regButton","Register","registerButton")."</div><br>";
        $loginWindow = "<div id='dialog-box-login' title='Sign In'>";
        $loginWindow .="<div style =' border: 1px solid transparent; padding: 7px' class='errorMessageDiv'> </div>";
        $loginWindow .="<div id='loginResponseDiv'> </div>";
        $postPath = $this->parsesiteconfig->getURLPath();
        $loginWindow .= "<form id='loginForm' action=$postPath method='post'>";
        $loginWindow .= $this->html_builder->buildTextInput('loginName', null, 'loginName', TRUE, "User Name",'top') . "<br>";
        $loginWindow .= $this->html_builder->buildPasswordInput('loginPassword', null, 'loginPassword', TRUE, "Password",'top') . "<br>";
        $this->html_builder->addOption('cricketfan', 'Cricket Fan');
        $this->html_builder->addOption('commentator', 'Commentator');
        $this->html_builder->setSelected('cricketfan');
        $loginWindow .= $this->html_builder->buildRadioButton('loginType', "Login as:")."<br>";
//        $this->html_builder->setButtonType('submit');
//        $loginWindow .=  $this->html_builder->buildButton("loginButton","Login","loginButton");
        $loginWindow .= "</form>";
        $loginWindow .= "</div>";
        return $loginWindow;
    }

        /**
     * \brief This function builds html content for the registration window.
     * \return This returns the html content for the registration window.
     */
    private function buildWebRegistrationWindow() {
        $registrationWindow = "<div id='dialog-box-registration' title='Register As a New User'>";
        $registrationWindow .="<div style =' border: 1px solid transparent; padding: 7px' class='errorMessageDiv'> </div>";
        $registrationWindow .="<div class='responseDiv'> </div>";
        $postPath = $this->parsesiteconfig->getURLPath();
        $registrationWindow .= "<form id='registrationForm' method='post' name='registration form'";
        $this->html_builder->addOption('cricketfan', 'Cricket Fan');
        $this->html_builder->addOption('commentator', 'Commentator');
        $this->html_builder->setSelected('cricketfan');
        // $this->html_buillder->setBreakSpace('new line');
        $registrationWindow .= $this->html_builder->buildRadioButton('userType', "Select what type of user you want to register as:");
        $registrationWindow .= $this->html_builder->buildTextInput('firstName', null, 'firstName', TRUE, "First Name", 'top') . "<br>";
        $registrationWindow .= $this->html_builder->buildTextInput('lastName', null, 'lastName', TRUE, "Last Name", 'top') . "<br>";
        $registrationWindow .= "<div id='nickNameInputContainer'>";
        $registrationWindow .= $this->html_builder->buildTextInput('nickName', null, 'nickName', TRUE, "Nick Name", 'top') . "<br>";
        $registrationWindow .= "</div><div id='profileInputContainer'>";
        $registrationWindow .= $this->html_builder->buildTextArea("commentatorProfile",'',"commentatorProfile", TRUE, 'Enter a description about yourself for a profile','top',6,34);
        $registrationWindow .= "</div>";
        $registrationWindow .= $this->html_builder->buildTextInput('emailAddress', null, 'emailAddress', TRUE, "Email Address", 'top') . "<br>";
        $registrationWindow .= $this->html_builder->buildTextInput('userName', null, 'userName', TRUE, "User Name", 'top') . "<br>";
        $registrationWindow .= $this->html_builder->buildPasswordInput('passwordField', null, 'passwordField', TRUE, "Password", 'top') . "<br>";
        $registrationWindow .= $this->html_builder->buildPasswordInput('repeatPasswordField', null, 'repeatPasswordField', TRUE, "Repeat Password", 'top') . "<br>";

        $registrationWindow .="</form>";
        $registrationWindow .= "</div>";
        return $registrationWindow;
    }

    /**
     * \brief This function builds html content for OK message of the
     * Registration box.
     * \return This returns  html content for OK message of the
     * Registration box.
     */
    private function buildWebRegistrationOKMessageBox() {
        return $this->html_builder->buildSimpleDialogueBox('dialogue-registrationOKMessage', 'Registration is Successful', 'Your Registration was successful. An email with your login details have been emailed to you.', 'ui-icon-circle-check');
    }

    /**
     * \brief This function builds html content for OK message of the
     * Registration box.
     * \return This returns  html content for OK message of the
     * Registration box.
     */
    public function showWebRegistrationWindow() {
        return $this->buildWebRegistrationWindow();
    }

    /**
     * \brief This function builds html content for OK message of the
     * Registration box.
     * \return This returns  html content for OK message of the
     * Registration box.
     */
    public function showWebRegistrationOKMessageBox() {
        return $this->buildWebRegistrationOKMessageBox();
    }


     /**
     * \brief Builds html content for the login window.
     * return Returns the html content for the login window for display.
     */
    public function showWebLoginWindow()
    {
        return $this->buildWebLoginWindow();
    }


}